/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import data.Employees;
import data.Jobrotation;
import data.Vacancyfilldetails;
import java.util.List;
import java.util.Set;
import util.BaseDAO;

/**
 *
 * @author Hùng
 */
public class EmployeeDAO extends BaseDAO {

    public List<Employees> getallEmployee() {
        String hql = "from Employees";
        List<Employees> lEmployee = executeHQLQuery(hql);
        return lEmployee;
    }

    public Employees getEbyUserName(String userName) {
        String hql = "from Employees a where a.username = '" + userName + "'";
        List<Employees> tmpE = executeHQLQuery(hql);
        if (tmpE.size() == 0) {
            return null;
        }
        return tmpE.get(0);
    }

    public Employees getEbyIdE(String idE) {
        String hql = "from Employees a where a.empid = '" + idE + "'";
        List<Employees> tmpE = executeHQLQuery(hql);
        if (tmpE.size() == 0) {
            return null;
        }
        return tmpE.get(0);
    }

    public Employees findEmpbyIdE(String idE) {
        String hql = "from Employees a where a.empid = '" + idE + "'";
        List<Employees> tmpE = executeHQLQuery(hql);
        if (tmpE.size() == 0) {
            throw new Error("Please,check your Id Employee.");
        }
        return tmpE.get(0);
    }
    public List<Employees> getEmployeesbyIdDesign(String idDesign){
        String hql = "from Employees a where a.designation = '"+idDesign+"'";
        List<Employees>  lE = executeHQLQuery(hql);
        if(lE != null){
            return lE;
        }
        return null;
    }

    
}
